package com.ygqh.baby.controller.admin;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ygqh.baby.ao.CheckStatus;
import com.ygqh.baby.ao.Message;

import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.po.YgPublishComment;
import com.ygqh.baby.service.YgPublishCommentService;

@Controller
@RequestMapping("/admin/publishComment")
public class PublishCommentController  extends BaseController<Object, java.lang.Long>{
	@Autowired
	private YgPublishCommentService ygPublishCommentService;
	
	@RequestMapping("searchPublishComment")
	@ResponseBody
	public Map<String,Object> searchPublishComment(String q,QueryInfo queryInfo,Date startDate,Date endDate,String pStatus,Long id) {	
		
		ResultSet<YgPublishComment> resultSet=ygPublishCommentService.search(queryInfo, q, id, pStatus, startDate, endDate);
		
		return resultSet.toDatatables(null);
	}
	
	//审批
	@RequestMapping("approvePublishComment")
	@ResponseBody
	public Message approvePublishComment(Long id,String remark,CheckStatus status){
		YgPublishComment ygPublishComment=new YgPublishComment();
		ygPublishComment.setId(id);
		ygPublishComment.setAuditStatus(status);
		ygPublishComment.setCheckBy(getSession().getTrueName());
		ygPublishComment.setCheckTime(new Date());
		ygPublishComment.setCheckRemark(remark);
		ygPublishCommentService.update(ygPublishComment);
		return SUCCESS_MESSAGE;
	}
	/**
	 * 批量审批
	 * @param id
	 * @param remark
	 * @param status
	 * @return
	 */
		@RequestMapping("batchApprovePublishComment")
		@ResponseBody
		public Message batchApprovePublishComment(Long[] ids,String remark,String status){
			
			ygPublishCommentService.updateBatchChechStatus(getSession().getTrueName(), status, ids);
			return SUCCESS_MESSAGE;
		}
	
	
}
